package com.mitake.nick.service;

import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import com.mitake.nick.bean.Contact;

@Controller
@SessionAttributes
public class ContactService {

	@RequestMapping(value = "/addContact", method = RequestMethod.POST)
    public String addContact(@ModelAttribute("contact") Contact contact, BindingResult result) {
         
        System.out.println("First Name:" + contact.getFirstname() + "Last Name:" + contact.getLastname());
        return "redirect:contacts.html";
    }
     
    @RequestMapping("/contacts")
    public ModelAndView showContacts() {
        return new ModelAndView("contact", "command", new Contact());
    }
}
